package com.acme.bankapp;

import java.io.IOException;

import com.acme.bankapp.domain.bank.Account;
import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.CheckingAccount;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.Gender;
import com.acme.bankapp.domain.bank.SavingAccount;
import com.acme.bankapp.exceptions.ClientExistsException;
import com.acme.bankapp.service.bank.BankDataLoader;
import com.acme.bankapp.service.bank.BankService;

public class BankApplication {
    public static void main(String[] args) throws IOException {
   	
    	Client[] clients = new Client[] {
    			new Client("Ivanov I.I.", Gender.MALE, new SavingAccount(10.00)),
    			new Client("Petrov P.P.", Gender.MALE, new SavingAccount(20.00)),
    			new Client("Sidorov S.S.", Gender.MALE, new SavingAccount(30.00)),
    			new Client("Frolova F.F.", Gender.FEMALE, new SavingAccount(40.00)),
    			new Client("Vasiljeva V.V.", Gender.FEMALE, new CheckingAccount(70.00, 70.00)),
    			new Client("Alekseeva A.A.", Gender.FEMALE, new CheckingAccount(80.00, 80.00))
    			};    	
    	final String path2F = "f:/1/filebank.txt";	// !!!!!!!!!!!!!!!!!!!!!!!!!
    	
    	Bank bank = new Bank(clients);
    	BankService bankService = new BankService();
    	
//    	Client newcl = new Client("Newvanov I.I.", Gender.MALE, new SavingAccount(50.00));
//   		BankService.addClient(bank, newcl);
//    	
//    	Client newcl1 = new Client("NewAnothervanov I.I.", Gender.MALE, new SavingAccount(60.00));
//   		BankService.addClient(bank, newcl1);
//    	
//   		Client newcl2 = new Client("NewAnothervanov I.I.", Gender.MALE, new CheckingAccount(777.00,1000.00));
//    	BankService.addClient(bank, newcl2);
//    	
//    	bankService.modifyBank(bank);
    	
    	BankDataLoader bankDataLoader = new BankDataLoader(bank);
    	bankDataLoader.saveBank(bank, path2F);

    	bankDataLoader.loadBank(bank, path2F, bankService);

    	bankService.printBalance(bank);
    }
}	
